package ysc.cqnu.operdb.serviceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ysc.cqnu.operdb.entity.Dye;
import ysc.cqnu.operdb.entity.ResultData;
import ysc.cqnu.operdb.mapper.ZhuoSeMapper;
import ysc.cqnu.operdb.service.CheckZhuoSeInfoService;

@Service
public class CheckZhuoSeInfoServiceImpl implements CheckZhuoSeInfoService {
    @Autowired
    private ResultData resultData;
    @Autowired
    private ZhuoSeMapper zhuoSeMapper;
    @Autowired
    private Dye dye;
    @Override
    public ResultData checkZhuoSeInfoService(String zhuosename, String renwu, String yongtu, String juti, String uploader, String uploadDate) {
        try {
            dye = zhuoSeMapper.chazhaoZhuoseInfo(zhuosename,renwu,yongtu,juti,uploader,uploadDate);

            if(dye!=null){
                int count = zhuoSeMapper.count();
                int site = zhuoSeMapper.zhuoseInfoSite(String.valueOf(dye.getId()));
                dye.Count=String.valueOf(count);
                dye.site=String.valueOf(site);
                resultData.flag="CheckSuccess";
                resultData.data=dye;
                return resultData;
            }
            else {
                resultData.flag="ZhuoseInfoNoFind";
                resultData.data=null;
                return resultData;
            }
        }catch (Exception e){
            resultData.flag="CheckFail";
            resultData.data=null;
            return resultData;
        }
    }
}
